// models/examine_task_model.dart
import 'package:flutter/cupertino.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class ExamineTaskModel {
  final String orderNo;
  final String platformId;
  final String nickName;
  final String submitTime;
  final String comment;
  final List<String> submitImages;
  final String status;

  double get commentLabelHeight {
    final textPainter = TextPainter(
      text: TextSpan(
        text: comment,
        style: const TextStyle(fontSize: 15, height: 1.4),
      ),
      maxLines: null,
      textDirection: TextDirection.ltr,
    );
    textPainter.layout(maxWidth: ScreenUtil.defaultSize.width - 23);
    return textPainter.size.height;
  }

  ExamineTaskModel({
    required this.orderNo,
    required this.platformId,
    required this.nickName,
    required this.submitTime,
    required this.comment,
    required this.submitImages,
    required this.status,
  });

  factory ExamineTaskModel.fromJson(Map<String, dynamic> json) {
    return ExamineTaskModel(
      orderNo: json['orderNo'] ?? '',
      platformId: json['platformId'] ?? '',
      nickName: json['nickName'] ?? '',
      submitTime: json['submitTime'] ?? '',
      comment: json['comment'] ?? '',
      submitImages: List<String>.from(json['submitImages'] ?? []),
      status: json['status'] ?? '',
    );
  }
}

enum ExamineTaskType {
  daishenhe, // 待审核
  yitongguo, // 已通过
  yijujue,   // 已拒绝
}

extension ExamineTaskTypeExtension on ExamineTaskType {
  String get displayName {
    switch (this) {
      case ExamineTaskType.daishenhe:
        return '待审核';
      case ExamineTaskType.yitongguo:
        return '已通过';
      case ExamineTaskType.yijujue:
        return '已拒绝';
    }
  }
}